interface TaskTemplate {
    data: any;
    checked: () => boolean;
}
class Task implements TaskTemplate {
    data: any;
    checked: () => boolean;
    constructor({ data, checked: isDone }: TaskTemplate) {
        this.data = data;
        this.checked = isDone;
    }
}

//! 尚未完成构思
export default class GameTask {
    // TaskList 包含 Task 数组，必须数组里面的 Task 都完成了，才会进入下一个 Task 数组
    private TaskList: Task[][];
    private doingIndex = 0;
    get process() {
        return (this.doingIndex + 1) / this.TaskList.length;
    }
    constructor(Input: TaskTemplate[][]) {
        this.TaskList = Input.map((Mission) => Mission.map((i) => new Task(i)));
    }
    check() {
        const allDone = this.TaskList[this.doingIndex].every((i) =>
            i.checked()
        );
        if (allDone) {
            if (this.doingIndex + 1 >= this.TaskList.length) {
                this.gameOver();
            } else {
                this.doingIndex++;
            }
            return true;
        } else {
            return false;
        }
    }
    replay() {
        this.doingIndex = 0;
        return true;
    }
    gameOver() {}
}
